home *** CD-ROM | disk | FTP | other *** search
/ Best of Shareware / Best of PC Windows Shareware 1.0 - Wayzata Technology (7111) (1993).iso / mac / DOS / UTILITY / WIZ26 / CALL_WIZ.C next >
C/C++ Source or Header  |  1991-09-18  |  2KB  |  83 lines

  1.  
  2. /* This program is used to test calling WIZ from another program,
  3.  * and prints out what is returned.
  4.  * I use Borland Turbo-C++ v 1.0.
  5. */
  6.  
  7. #include <stdio.h>
  8. #include <dos.h>
  9.  
  10. /* This is the signature block of the inter-task communication area,
  11.  * between WIZ and the calling program.
  12.  * It must be in the 1st 64K bytes of the calling program.
  13.  * We find it by looking for the two signature words, and the
  14.  * psp being the same segment as the memory control block.
  15.  * -----
  16.  * Then we fill in the area with ASCIZ strings (ending with another
  17.  * NULL, same as the way environment strings are.)
  18.  * The number of strings is returned in ica_size (NOT total size).
  19.  * WIZ will make sure to not overflow this area.  If "ica_size" does not
  20.  * change, then WIZ didn't do anything.
  21.  *
  22.  * WIZ will set "ica_retf" to '.' when it starts.  If any strings would
  23.  * not fit in the area, "ica_retf" gets set to '+'.
  24. */
  25. struct itc_comm_area {
  26.    int ica_size;          /* Size of the itc_comm_area (bytes) */
  27.    char ica_retf;          /* '+' if WIZ couldn't store all the strings */
  28.    char ica_signature_1[8];   /* Signature 1 */
  29.    unsigned int ica_psp;      /* psp segment */
  30.    char ica_signature_2[4];   /* Signature 2 */
  31.  
  32.    #define ICA_SIGN_1 "Wiz Area"
  33.    #define ICA_SIGN_2 "CRVT"
  34. };
  35.  
  36.  
  37.  
  38. static char the_ica[100];
  39.  
  40. main()
  41. {
  42.    struct itc_comm_area *p_ica;
  43.    int i;
  44.    char cmd_line[80];
  45.    char *s;
  46.  
  47.    p_ica = (struct itc_comm_area *)&the_ica;
  48.    puts("Try invoking WIZ with some parameters, & get return");
  49.    go_set_up_ica();
  50.  
  51.    sprintf(cmd_line, "WIZ -p -z%d c:*.bat", _psp);
  52.    system(cmd_line);
  53.    printf("# of strings returned by WIZ: %d\n", p_ica->ica_size);
  54.    printf("Retf is: \"%c\".\n", p_ica->ica_retf);
  55.  
  56.    for (s = p_ica->ica_signature_1; *s != 0; ) {
  57.       printf("%s\n", s);
  58.       s += strlen(s) +1;
  59.    }
  60. }
  61.  
  62.  
  63.  
  64.  
  65. /*****************************/
  66. /*** Set up the ica_area. ****/
  67. go_set_up_ica() {
  68.  
  69.       struct itc_comm_area *p_ica;
  70.  
  71.       p_ica = (struct itc_comm_area *)&the_ica;
  72.       memset(the_ica, 0x55, 100);
  73.  
  74.       p_ica->ica_size = sizeof(the_ica);
  75.       memcpy(p_ica->ica_signature_1, ICA_SIGN_1, 8);
  76.       memcpy(p_ica->ica_signature_2, ICA_SIGN_2, 4);
  77.       p_ica->ica_psp = _psp;
  78.       printf("My ica is at %08lx\n", (char far *)&the_ica);
  79.    };
  80.  
  81.  
  82.  
  83.